/*
 * XmegaADC.c
 *
 * Created: 4/10/2011 10:41:32
 *  Author: morpheus
 */ 
 #include "XmegaADC.h"


void init_adc (void) 
{ 
  ADCA.CTRLA = 0x01; 
  //ADC enable 
  ADCA.CTRLB = 0x04;
  
  //unsigned mode* und 8Bit 
  ADCA.REFCTRL = 0x00;
}
int readADC()
{       

      uint8_t temp;
      
      //input mode single ended channel 0, the measurement is started
	    ADCA.CH0.CTRL = 0x81;
      
	    //??result of the measurement is stored in temp 
	    return ADCA_CH0RES; 
}      
  
